<template>
  <div class="withdraw">
    <!--查询表单-->
    <el-form :inline="true" class="demo-form-inline">
      <el-form-item>
        <el-input placeholder="用户名" />
      </el-form-item>
      <el-form-item label="添加时间">
        <el-date-picker
          type="datetime"
          placeholder="选择开始时间"
          value-format="yyyy-MM-dd HH:mm:ss"
          default-time="00:00:00"
        />
      </el-form-item>
      <el-form-item>
        <el-date-picker
          type="datetime"
          placeholder="选择截止时间"
          value-format="yyyy-MM-dd HH:mm:ss"
          default-time="00:00:00"
        />
      </el-form-item>
      <el-button type="primary" icon="el-icon-search" @click="getList()">查询</el-button>
      <el-button type="default" @click="resetData()">清空</el-button>
    </el-form>
    <!-- 表格 -->
    <el-table :data="withdraw">
      <el-table-column prop="id" label="编号" width="80" align="center" />
      <el-table-column prop="realname" label="用户名" />
      <el-table-column prop="gender" label="性别" />
      <el-table-column prop="telephone" label="手机号" />
      <el-table-column prop="bankCard" label="银行卡号" />
      <el-table-column prop="registerTime" label="注册时间" />
      <el-table-column prop="balance" label="余额" align="center" />
      <el-table-column label="操作" fixed="right" align="center">
        <template slot-scope="scope">
          <el-button type="primary" size="mini" @click="shenhe(scope.row)">审核</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 表格结束 -->
    <!-- 模态框 -->
    <el-dialog title="提现审核" :visible.sync="visible">
      <p>用户名：{{this.cus.realname}}</p>
      <p>身份证号：{{this.cus.idCard}}</p>
      <!-- {{this.cus}} -->
      <p>手机号：{{this.cus.telephone}}</p>
      <p>银行卡号：{{this.cus.bankCard}}</p>
      <p>提现金额：{{this.cus.balance}}</p>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submit">审核通过</el-button>
        <el-button type="danger" @click="refuse">审核未通过</el-button>
      </div>
    </el-dialog>
    <!-- 模态框结束 -->
  </div>
</template>
<script>
import { get } from '@/utils/request'
export default {
  data() {
    return {
      visible: false,
      withdraw: [],
      cus: []
    }
  },
  created() {
    this.loadWithdraw()
  },
  methods: {
    loadWithdraw() {
      let url = 'http://47.93.12.6:8889/user/findAllCustomer'
      get(url).then(response => {
        this.withdraw = response.data
      })
    },
    shenhe(row) {
      this.cus = row
      this.visible = true
    },
    submit() {
      let url = 'http://47.93.12.6:8889/user/withdraw'
      get(url, { id: this.cus.id }).then(response => {
        this.$message({ type: 'success', message: response.message })
        this.loadWithdraw()
      })
      this.visible = false
    },
    refuse() {
      let url = 'http://47.93.12.6:8889/user/refusewithdraw'
      get(url, { id: this.cus.id }).then(response => {
        this.$message({ type: 'success', message: response.message })
        this.loadWithdraw()
      })
      this.visible = false
    }
  }
}
</script>